package com.yl.chainStore.services.impl.sick

import com.yl.chainStore.entity.sick.SickConsultRecordDetail
import com.yl.chainStore.mapper.sick.SickConsultRecordsDetailMapper
import com.yl.chainStore.pojo.vo.sick.SickConsultRecordsDetailSelectVo
import com.yl.chainStore.services.IConsultRecordService
import com.yl.common.control.ResponseBody
import com.yl.common.control.returnSuccess
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

@Service
class IConsultRecordServiceImpl(
  private val sickConsultRecordsDetailMapper: SickConsultRecordsDetailMapper
) : IConsultRecordService {


  companion object {
    private val log = LoggerFactory.getLogger(IConsultRecordService::class.java)
  }

  override fun saveRecord(vo: SickConsultRecordDetail): ResponseBody {
    log.info("客户操作：==>增加咨询记录")
    sickConsultRecordsDetailMapper.insert(vo)
    return returnSuccess()
  }


  override fun getRecord(id: Long): ResponseBody {
    log.info("客户操作：==>查询咨询记录")
    val recordDetail = sickConsultRecordsDetailMapper.selectById(id)
    return returnSuccess(recordDetail)
  }

  override fun delRecordById(id: Long): ResponseBody {
    log.info("页面配置 ==> 删除字段 ：id:{}", id)
    sickConsultRecordsDetailMapper.deleteById(id)
    return returnSuccess()
  }


  override fun updateRecord(sickConsultRecordDetail: SickConsultRecordDetail): ResponseBody {
    log.info("客户操作 ==>修改记录 ==>updateRecord:{} ", sickConsultRecordDetail)
//    var record = this.sickConsultRecordsDetailMapper.selectById(sickConsultRecordDetail.id)
    this.sickConsultRecordsDetailMapper.updateById(sickConsultRecordDetail)
    return returnSuccess()
  }

  override fun getCustomerConsultRecordsDetailList(vo: SickConsultRecordsDetailSelectVo): List<SickConsultRecordDetail> {
    log.info("客户操作：==> 获取咨询记录明细列表：vo{}", vo)
    return this.sickConsultRecordsDetailMapper.getList(vo)
  }
}
